#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

// 1865. 找出和为指定值的下标对
// https://leetcode.cn/problems/finding-pairs-with-a-certain-sum/description/?envType=daily-question&envId=2025-07-06

class FindSumPairs
{
public:
    FindSumPairs(vector<int> &nums1, vector<int> &nums2)
        : mNums2(nums2.begin(), nums2.end()), mNums1(nums1.begin(), nums1.end())
    {
        for (int i = 0; i < nums2.size(); i++)
        {
            num2Freq[nums2[i]]++;
        }
    }

    void add(int index, int val)
    {
        if (index >= mNums2.size())
        {
            return;
        }
        num2Freq[mNums2[index]]--;
        mNums2[index] += val;
        num2Freq[mNums2[index]]++;
    }

    int count(int tot)
    {
        int ans = 0;
        for (auto n : mNums1)
        {
            if (n > tot || num2Freq.find(tot - n) == num2Freq.end())
            {
                continue;
            }
            ans += num2Freq[tot - n];
        }
        return ans;
    }

private:
    unordered_map<int, int> num2Freq;
    vector<int> mNums2;
    vector<int> mNums1;
};

int main()
{
    return 0;
}